<template>
    <div class="demo flex-center-center">
        <el-form ref="form" :model="form" label-width="120px">
            <el-form-item label="强口令密码判断:">
              <el-input v-model="inputStr" placeholder="请输入强口令密码密码" clearable></el-input>
              <el-button type="primary" icon="el-icon-search" @click="doSearchPwd">查询</el-button>
              <span v-if="isinputStr">{{pwdVal ? '是' :'否'}}</span>
            </el-form-item>
            <el-form-item label="生成安全口令:">
              <el-select v-model="policyId" placeholder="选择策略ID" clearable>
                <el-option :key="item.id" :label="item.name" :value="item.id" v-for="item in IDList" ></el-option>
              </el-select>
              <el-input v-model="pwdLen" placeholder="请输入密码(最大长度200)" maxlength="200" clearable></el-input>
              <el-button type="primary" icon="el-icon-search" @click="doSearchId">查询</el-button>
              <span>{{passwrodVal ? passwrodVal:''}}</span>
            </el-form-item>
        </el-form>
    </div>
</template>
<script>
  var that = null;

  export default {
    data() {
      return {
        IDList:[
          {id:0,name:'0'},
          {id:1,name:'1'},
          {id:2,name:'2'},
          {id:3,name:'3'}, ],

        inputStr:'', //1.强口令
        pwdVal:'',
        policyId:'0',
        pwdLen:'',
        passwrodVal :'',
        isinputStr:false
      };
    },
    created() {
      that = this;
    },
    methods: {
      doSearchPwd(){
        let inputStr = that.inputStr
        let url = 'http://100.95.131.203:8080/pwd/isStrong'
        get(url,{
          inputStr
        }).then(res=>{
          that.pwdVal  = res.data
          that.isinputStr = true
        })


      },
      doSearchId(){
        let id = that.id
        let password = that.password
        let url = 'http://100.95.131.203:8080/pwd/generateByPolicy'
        get(url,{
          policyId,pwdLen
        }).then(res=>{
          that.passwrodVal  = res.data
        })

      }
    },
  };
</script>
<style lang="scss">
.demo{
width: 800px;
height: 400px;
margin: 250px auto;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
.el-form{
.el-input{
width: 240px;
}
.el-button{
margin-left: 20px;
}
.el-select{
margin-right: 20px;
}
}
}
</style>